<template>
    <div style="padding-bottom: 40px;">
       <v-touch v-on:swiperight="onSwipeRight" :swipe-options="{direction: 'horizontal'}">
        <x-header title="消息详情" :left-options="{backText:'',preventGoBack:true}"
                @on-click-back="toHomeAndRead">
        </x-header>
        <div v-if="obj.TITLE != ''" class="forSwipeRight">
            <div class="title">{{obj.TITLE}}</div>
            <span class="datetime">{{obj.SENTTIME.substring(0,10)}}</span>
            <div class="data-content" v-html="obj.CONTENT">
              <!-- <group>
                <x-textarea readonly="true" :title="obj.CONTENT"></x-textarea>
              </group> -->
            </div>
        </div>
        <div v-if="obj.TITLE == ''" class="forSwipeRight">
            <div class="title">紧急通知</div>
            <span class="datetime">{{obj.CREATETIME.substring(0,10)}}</span>
            <div class="data-content" v-html="obj.NOTICE"></div>
        </div>
        <!-- <div style="width:100%;height:20px;background-color:#f5f5f5"></div>
         <footer class="footer">
           <div class="attachment">附件</div>
          <div v-if="fileNameItem.length > 0" v-for="(i, index) in fileNameItem" class="file" @click="checkFile(i.fileId, i.fileOldName, i.fileSize)">
            <img src="../../svg/pdf.svg" alt="" class="file-icon">
            <div>
            <div class="file-name">{{i.fileOldName}}</div>
            <div class="file-size">{{i.fileSize}} KB</div>
            </div>
          </div>
          <div v-if="fileNameItem.length == 0">
            <div class="content">暂无附件</div>
          </div>
        </footer> -->
       </v-touch>
    </div>
</template>

<script>
import { XTextarea,Group } from 'vux'
export default {
    name:"systemDetailInfo",
    comments:{
      XTextarea,
      Group
    },
    created(){
        this.obj = this.$route.params.item
        // this.getFileName(this.obj.CONTENTATTACHMENTID)
    },

    data(){
        return {
            obj : [],
            // fileNameItem:[],
        }
    },

    methods:{
      onSwipeRight(){
         if(this.obj.TITLE != ''){
           var params = '{"_method":"SYS_NOTICE.updateNoticeIsRead","pkid":"' + this.obj.PKID +
          '","messageto":"' + this.obj.MESSAGETO +'"}';

          this.$ajax({
            method : 'post',
            url : this.COMMON_URL ,//+ '?_isBreak=false&objName=SYS_NOTICE&_useType=view&_pk=PKID&_pkValue=',
            // data : this.signMD5({
            //   FixJSON : params
            // })
            data : {
                    FixJSON : params
                }
          }).then(res =>{
            this.$router.go(-1)
          })
        }else{
          this.$router.go(-1)
        }
      },
      //消息通知返回后已阅
      toHomeAndRead(){
        if(this.obj.TITLE != ''){
           var params = '{"_method":"SYS_NOTICE.updateNoticeIsRead","pkid":"' + this.obj.PKID +
          '","messageto":"' + this.obj.MESSAGETO +'"}';

          this.$ajax({
            method : 'post',
            url : this.COMMON_URL ,//+ '?_isBreak=false&objName=SYS_NOTICE&_useType=view&_pk=PKID&_pkValue=',
            // data : this.signMD5({
            //   FixJSON : params
            // })
            data : {
                    FixJSON : params
                }
          }).then(res =>{
            this.$router.go(-1)
          })
        }else{
          this.$router.go(-1)
        }
      }
        // getFileName(fileToken){
        //   console.log(fileToken)
        //   var params = `{"_method":"streamSupportService.getAttachmentInfos","_param":[{"fieldToken":"`+ fileToken +`"}]}`;
        //   this.$ajax({
        //     url: this.COMMON_URL,
        //     method : 'post',
        //     data: {
        //       FixJSON: params
        //     }
        //   }).then(res => {
        //     this.fileNameItem = res.data.attachments;
        //     console.log(this.fileNameItem);
        //   });
        // }
    }
}
</script>

<style scoped>
.forSwipeRight{
  width: 100%;
  height: -webkit-fill-available;
}
.title{
    font-size:18px;
    font-family:PingFangSC-Regular;
    font-weight:400;
    color:#191919FF;
    line-height:26px;
    margin-left: 5%;
    margin-top: 15px;
}
.datetime{
    font-size:12px;
    font-family:PingFangSC-Regular;
    font-weight:400;
    color:#999999;
    line-height:20px;
    margin-left: 5%;
}
.data-content{
    font-size:16px;
    font-family:PingFangSC-Regular;
    font-weight:400;
    color:#333333FF;
    line-height:28px;
    margin: 5%;
    /*按文本域格式显示文本*/
    white-space: pre-wrap;
}
/* .footer{
  padding-top: 16px;
} */
.attachment{
  font-size:16px;
  font-family:PingFangSC-Regular;
  font-weight:600;
  color:#191919;
  line-height:28px;
  margin-left: 5%;
  margin-top: 3%;
}
.file{
    display: flex;
    align-items: center;
    position: relative;
    padding-bottom: 16px;
    margin-top: 5%;
  }
 .file-icon{
    width: 32px;
    height: 32px;
    margin-left: 5%;
  }
    .file-name{
    margin-left: 16px;
    font-size: 12px;
    color: #343434;
  }
  .file-size{
    font-size: 11px;
    color: #9f9f9f;
    margin-left: 16px;
  }
/* .transition-view /deep/ .vux-header{
    background-color: #ffffff !important;
  } */
  /* .transition-view /deep/ .vux-header .vux-header-title > span{
    font-size:18px;
    font-family:PingFang SC;
    font-weight:600;
    line-height:20px;
  } */
  .transition-view  /deep/ .vux-header .vux-header-left .left-arrow:before{
    border-color:   #cccccc;
  }
  .data-url{
    font-size: 16px;
    font-family: PingFangSC-Regular;
    font-weight: 400;
    color: #333333;
    line-height: 28px;
    margin: 5%;
    white-space: pre-wrap;

  }
</style>
